#pragma unmanaged
#pragma once

#include "cell.h"

namespace O1 {
	namespace Storage {
		namespace Memory {

			using cell_store = std::vector < cell >;

			class trunk {
			
			private:
				cell_store* store;

			public:
				void initialize(long long size);
				
				void clear();

				long long add_cell(byte* const &value, const int sz); 

				inline long long write_cell(const long long index, byte* const &value, const int sz) {
					this->store->at(index).swap(cell(value, sz));
					return index;
				};

				inline long long delete_cell(const long long index) {
					this->store->at(index).swap(cell(nullptr, 0));
					return index;
				};

				inline const cell* read_cell(const long long index) const {
					return &this->store->at(index);
				};
			};
		}
	}
}

